﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace brockredge
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["userId"] == null)
            {
                lblLo.Text = "Login";
                lblReg.Text = "Register";
                lblinklo.PostBackUrl = "NewAccount.aspx";
            }
            else
            {
                lblLo.Text = "Logout";
                lblinklo.PostBackUrl = "Logout.aspx";
            }
            if (Page.IsPostBack)
                    return;

            DisplayAllAdd();
        }
        private void DisplayAllAdd()
        {
            testDataContext tdc = new testDataContext();
            var addvertisementQ = from add in tdc.Advertisements
                                  orderby add.createDate descending
                                  select add;

            if (addvertisementQ.Count() > 0)
            {
                topAddRep.DataSource = addvertisementQ;
                topAddRep.DataBind();
            }
        }
    }
}
